package com.zh.yqbj.service;

import com.zh.yqbj.dto.*;
import com.zh.yqbj.exception.accountExcption.*;
import com.zh.yqbj.VO.LoginVO;
import com.zh.yqbj.entity.User;
import org.jetbrains.annotations.NotNull;

import javax.mail.MessagingException;
import java.io.UnsupportedEncodingException;

public interface AccountService {
    /**
     * 用户登录
     *
     * @param userLoginDTO userLoginDTO
     * @return UserVO
     * @throws UnknownAccountException      用户不存在
     * @throws ErrorPasswordException       密码错误
     * @throws ErrorCodeException           验证码错误
     * @throws ErrorPhonePatternException   手机号格式错误
     * @throws ErrorEmailPatternException   邮箱格式错误
     * @throws NoMoneyException             欠费
     * @throws MessagingException           MessagingException
     * @throws UnsupportedEncodingException UnsupportedEncodingException
     */
    LoginVO userLogin(UserLoginDTO userLoginDTO) throws UnknownAccountException, ErrorPasswordException,
            ErrorCodeException, ErrorPhonePatternException, ErrorEmailPatternException, RregisterException;

    LoginVO loginByUsername(UserLoginDTO userLoginDTO) throws UnknownAccountException, ErrorPasswordException;

    LoginVO loginByEmail(UserLoginDTO userLoginDTO) throws ErrorCodeException, RregisterException;

    LoginVO loginByPhone(UserLoginDTO userLoginDTO) throws ErrorCodeException, RregisterException;

    /**
     * 用户登出
     */
    void userLogout();

    /**
     * 发送验证码
     *
     * @param sendCodeDTO username,phone,email
     * @return key
     * @throws MessagingException           发送异常
     * @throws UnsupportedEncodingException 不支持的编码
     * @throws NoMoneyException             欠费
     */
    String sendCode(SendCodeDTO sendCodeDTO) throws MessagingException, UnsupportedEncodingException, NoMoneyException;

    /**
     * 发送邮箱验证码
     *
     * @param to 目的邮箱
     * @return key
     * @throws MessagingException
     * @throws UnsupportedEncodingException
     */
    String sendCodeByEmail(String to) throws MessagingException, UnsupportedEncodingException;

    /**
     * 发送手机验证码
     *
     * @param phone 目的手机号
     * @return key
     * @throws NoMoneyException 欠费
     */
    String sendCodeByPhone(@NotNull String phone) throws NoMoneyException;

    /**
     * 用户注册
     *
     * @param userRegisterDTO userRegisterDTO
     * @throws ErrorUsernamePatternException 用户名格式错误
     * @throws ErrorRepasswordException      两次密码不一致
     * @throws ErrorCodeException            验证码错误
     * @throws DuplicateAccountException     用户名重复
     * @throws ErrorPhonePatternException    手机号格式错误
     * @throws ErrorEmailPatternException    邮箱格式错误
     */
    void userRegister(UserRegisterDTO userRegisterDTO) throws ErrorUsernamePatternException, ErrorRepasswordException
            , RregisterException, DuplicateAccountException, ErrorCodeException, ErrorPhonePatternException,
            ErrorEmailPatternException;


    /**
     * 绑定/解绑邮箱
     *
     * @param bindEmailDTO 邮箱是否为空
     * @return 绑定/解绑通知
     * @throws ErrorCodeException
     * @throws DuplicateEmailException
     * @throws ErrorEmailPatternException
     */
    String bindingEmail(BindEmailDTO bindEmailDTO) throws ErrorCodeException, DuplicateEmailException,
            ErrorEmailPatternException;

    /**
     * 绑定/解绑手机号
     *
     * @param bindPhoneDTO 手机号是否为空
     * @return 绑定/解绑通知
     * @throws ErrorCodeException
     * @throws DuplicateEmailException
     * @throws ErrorPhonePatternException
     */
    String bindingPhone(BindPhoneDTO bindPhoneDTO) throws ErrorCodeException, DuplicateEmailException,
            ErrorEmailPatternException, ErrorPhonePatternException, DuplicatePhoneException;

    /**
     * 修改个人信息，对于账号密码需要验证码
     * 这个接口不负责更新手机号，邮箱
     *
     * @param userUpdateDTO 是否完善账号密码
     * @return 修改的类型
     */
    String updateUser(UserUpdateDTO userUpdateDTO) throws ErrorCodeException, ErrorPhonePatternException,
            ErrorEmailPatternException, ErrorUsernamePatternException, ErrorRepasswordException,
            DuplicateAccountException, DuplicatePhoneException, DuplicateEmailException;

    /**
     * 如果是手机号注册的 完善账号，密码
     * @param phone
     * @param username
     * @param newPwd
     * @param imageBase64
     * @param code
     * @return
     * @throws ErrorPhonePatternException
     * @throws DuplicateAccountException
     * @throws ErrorCodeException
     * @throws DuplicatePhoneException
     */
    String completeByPhone(String phone, String username, String newPwd, String imageBase64, String code) throws ErrorPhonePatternException, DuplicateAccountException, ErrorCodeException, DuplicatePhoneException;

    /**
     * 如果是邮箱注册的 完善账号，密码
     * @param email
     * @param username
     * @param newPwd
     * @param imageBase64
     * @param code
     * @return
     * @throws ErrorEmailPatternException
     * @throws DuplicateAccountException
     * @throws ErrorCodeException
     * @throws DuplicateEmailException
     */
    String completeByEmail(String email, String username, String newPwd, String imageBase64, String code) throws ErrorEmailPatternException, DuplicateAccountException, ErrorCodeException, DuplicateEmailException;

    /**
     * 修改个人基本信息
     * @param userUpdateDTO
     * @return
     */
    String updateInfo(UserUpdateDTO userUpdateDTO);

    /**
     * 重置密码，在忘记密码之后
     * @param refundPwdDTO
     * @return
     * @throws ErrorCodeException
     * @throws ErrorPhonePatternException
     * @throws UnBindingPhoneException
     * @throws UnknownAccountException
     */
    String refundPwd(RefundPwdDTO refundPwdDTO) throws ErrorCodeException, ErrorPhonePatternException, UnBindingPhoneException, UnknownAccountException, ErrorEmailPatternException, UnBindingEamilException;

    /**
     * 修改密码 在线操作的 需要精细校验
     * @param updatePwdDTO
     */
    void updatePwd(UpdatePwdDTO updatePwdDTO) throws UnknownAccountException, ErrorPasswordException, ErrorRepasswordException, ErrorCodeException;
}
